package com.dcbeida.utils;

import org.json.JSONObject;

import com.dcbeida.bean.ResultModel;

/**
 * Created by hp on 2016/7/8.
 */
public class JSONFunctions {

    public static ResultModel doJson(JSONObject json) {
        ResultModel ret = new ResultModel();
        if (json.has("code")) {
            ret.setErrcode(json.optInt("code"));
        }
        if (json.has("msg")) {
            ret.setErrmsg(json.optString("msg"));
        }

        if(json.has("data"))
            ret.setData(json.optJSONObject("data"));
        return ret;
    }
}
